<template>
	<view class="">
		<view class="head p2432 bgf">
			<view class="flex">
				<view class="flex_c">
					<image class="img_shop br4" :src="shop_details.image_str" mode=""></image>
				</view>
				<view class="ml20 flex1">
					<view class="fs28 c3 fw500 sn2">{{shop_details.title}}</view>
					<view class="flex mt12">
						<image class="icon1" src="/static/classify/dz.png" mode=""></image>
						<view class="fs24 c6 ml10 flex1">{{shop_details.address}} {{shop_details.detailed}}</view>
					</view>
				</view>
			</view>
			<view class="flex_c bg2a7 btn1 mt24" @click="toOperationState">
				<view class="fs28 cf mr10">
					<text v-if="shop_details.status == 'normal'">营业中</text>
					<text v-else>休息中</text>
				</view>
				<view class="flex_x">
					<u-icon name="play-right-fill" color="#fff" size="24rpx"></u-icon>
				</view>
			</view>
		</view>
		<view class="m2432 flex_ard fs24 c3 bgf list br12 ptb30">
			<view class="flex_col flex_x" v-for="item in men_list" :key="item.id" @click="toPath(item)">
				<image class="img60" :src="item.img" mode=""></image>
				<view class="">{{item.name}}</view>
			</view>
		</view>
		<view class="bgf br12 p24 mlr32">
			<view class="flex_btw mb30">
				<view class="fs30 fw500 c3">经营数据</view>
				<view class="flex_x" @click="finance">
					<text class="pr10 fs26 c9">更多</text>
					<u-icon name="arrow-right" color="#999" size="26rpx"></u-icon>
				</view>
			</view>
			<view class="sj br12">
				<view class="c3 fs30 fw500 mb20">今日数据</view>
				<view class="flex_ard flex_x plr20">
					<view class="flex_col flex_x">
						<view class="fs36 cf0 fw600">{{shop_num.today_num}}</view>
						<view class="fs28 c3 mt12">订单量</view>
					</view>
					<view class="line">
					</view>
					<view class="flex_col flex_x">
						<view class="fs36 cf0 fw600">¥{{shop_num.money_revenue}}</view>
						<view class="fs28 c3 mt12">获得佣金</view>
					</view>
				</view>
			</view>
			<view class="sj br12 pr mt40">
				<view class="c3 fs30 fw500 mb20">昨日数据</view>
				<view class="flex_ard flex_x plr20">
					<view class="flex_col flex_x">
						<view class="fs36 c2a7 fw600">{{shop_num.yesterday_num}}</view>
						<view class="fs28 c3 mt12">订单量</view>
					</view>
					<view class="line">
					</view>
					<view class="flex_col flex_x">
						<view class="fs36 c2a7 fw600">¥{{shop_num.yesterday_revenue}}</view>
						<view class="fs28 c3 mt12">获得佣金</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		components: {},
		data() {
			return {
				shop_details: '', //店铺详情
				shop_num: '', //数据统计
				men_list: [ //菜单列表
					{
						id: 1,
						name: '店铺管理',
						img: '/static/sever/tongji3.png',
						path: '/pages/server/index/bizManage/bizManage'
					},
					{
						id: 2,
						name: '店铺公告',
						img: '/static/sever/gg.png',
						path: '/pages/server/index/announcement/announcement'
					},
					{
						id: 3,
						name: '订单扫码',
						img: '/static/sever/tixian.png',
						path: ''
					},
					{
						id: 4,
						name: '财务管理',
						img: '/static/sever/shezhi.png',
						path: '/pages/server/index/finance/finance'
					}
				],
			}
		},
		beforeDestroy() {
			uni.$off('refresh') //移除监听事件
		},
		created() {
			uni.$on('refresh', (params) => {
				this.shopIndex()
			})
		},
		methods: {
			shopIndex() { //首页数据
				this.$api.shopIndex().then(res => {
					if (res.code == 1) {
						this.shop_details = res.data
						this.statistics()
					}
				})
			},
			statistics() { //服务点数据统计
				this.$api.statistics().then(res => {
					if (res.code == 1) {
						this.shop_num = res.data
					}
				})
			},
			toOperationState() { //跳转营业状态
				uni.navigateTo({
					url: `/pages/server/index/operationState/operationState?type=${this.shop_details.status}`
				})
			},
			toPath(item) { //跳转
				if (item.id == 3) { //订单扫码
					//type 2确认送回 3确认归还
					// uni.navigateTo({
					// 	url:'/pages/server/getOrder/washdetail/washdetail?type=3'
					// })
					// 允许从相机和相册扫码
					uni.scanCode({
						success: (res) => {
							console.log(res)
							console.log('条码类型：' + res.scanType)
							console.log('条码内容：' + res.result)
						}
					});
				} else {
					uni.navigateTo({
						url: item.path
					})
				}
			},
			finance() { //更多 财务管理
				uni.navigateTo({
					url: '/pages/server/index/finance/finance'
				})
			}
		},
		computed: {

		},
		watch: {

		}
	}
</script>

<style lang="scss" scoped>
	.head {
		box-shadow: 0px 1ypx 4ypx 0px rgba(0, 0, 0, 0.1);

		.img_shop {
			width: 200upx;
			height: 150upx;
		}
	}

	.icon1 {
		width: 29upx;
		height: 32upx;
	}

	.btn1 {
		width: 184upx;
		height: 58upx;
		border-radius: 30upx;
	}

	.list {
		box-shadow: 0px 2upx 6upx 0px rgba(14, 14, 14, 0.1);
	}

	.sj {
		border: 2upx solid #2A71C0;
		padding: 10upx 20upx 24upx 20upx;

		.line {
			width: 1upx;
			height: 60upx;
			background: #333333;
		}
	}
</style>
